unit uFrm08FuncHistory;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ComCtrls, Buttons, ExtCtrls, dxDBGrid, dxTL, dxDBCtrl, dxCntner,
  Db, DBClient;

type
  TFrm08FuncHistory = class(TForm)
    PnlTop: TPanel;
    PnlToolBar: TPanel;
    Bevel1: TBevel;
    Bevel2: TBevel;
    SpbtnRefresh: TSpeedButton;
    SpbtnAdd: TSpeedButton;
    SpbtnEdit: TSpeedButton;
    SpbtnDel: TSpeedButton;
    SpbtnSave: TSpeedButton;
    SpbtnCancel: TSpeedButton;
    SpbtnExport: TSpeedButton;
    SpbtnPrint: TSpeedButton;
    SpbtnFirst: TSpeedButton;
    SpbtnPrivor: TSpeedButton;
    SpbtnNext: TSpeedButton;
    SpbtnLast: TSpeedButton;
    SpbtnExit: TSpeedButton;
    SpbtnFind: TSpeedButton;
    Bevel3: TBevel;
    Bevel4: TBevel;
    Bevel5: TBevel;
    Bevel6: TBevel;
    Bevel7: TBevel;
    Panel7: TPanel;
    GroupBox1: TGroupBox;
    Label1: TLabel;
    DTPA: TDateTimePicker;
    DTPB: TDateTimePicker;
    PageControl1: TPageControl;
    TabSheet1: TTabSheet;
    dxDBGrid1: TdxDBGrid;
    dxDBGrid1sDevname: TdxDBGridMaskColumn;
    dxDBGrid1Column6: TdxDBGridColumn;
    dxDBGrid1Column5: TdxDBGridColumn;
    dxDBGrid1Column4: TdxDBGridColumn;
    dxDBGrid1Column7: TdxDBGridColumn;
    dxDBGrid1Column8: TdxDBGridColumn;
    dxDBGrid1Column9: TdxDBGridColumn;
    dxDBGrid1Column10: TdxDBGridColumn;
    dxDBGrid1Column11: TdxDBGridColumn;
    dxDBGrid1Column12: TdxDBGridColumn;
    DataSource1: TDataSource;
    CDSDBA: TClientDataSet;
    btnRefresh: TSpeedButton;
    dxDBGrid1Column13: TdxDBGridColumn;
    Label2: TLabel;
    edtUser: TEdit;
    Label3: TLabel;
    edtDevice: TEdit;
    procedure FormShow(Sender: TObject);
    procedure btnRefreshClick(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure SpbtnExportClick(Sender: TObject);
    procedure dxDBGrid1MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure SpbtnExitClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
{uFrmMD02 ref}
implementation
uses uFuntionSys, uFunDx,uDM, uDataSys, uFrm03AddStation;
{$R *.DFM}

procedure TFrm08FuncHistory.FormShow(Sender: TObject);
begin
    DTPA.DateTime := now;  DTPB.DateTime := now;
    PReadAndSaveFormALL(Self,true);
    DTPA.DateTime:=dMonthFirst();
    PSetOrderPnlBtn(PnlToolBar);
    PSetToolBarStyle(PnlToolBar,bSYSShowBtnCaption);
end;

procedure TFrm08FuncHistory.btnRefreshClick(Sender: TObject);
var
  Str:String;
  args:String;
begin
    Str:='Select T1.sMC, T1.sDVNO,T0.* from  TBD03_oper_history T0, TAD03_device T1 where sDateYMD>='''
         + FZDateStr(DTPA.DateTime, false) +
          ''' and sDateYMD<=''' + FZDateStr(DTPB.DateTime, false)
          + ''' and T1.FZID=T0.sDevFZID';

    if edtUser.Text <> '' then begin
       args :=  args + ' and sUser=''' + edtUser.Text + '''';
    end;

    if edtDevice.Text <> '' then begin
       args :=  args + ' and (T1.sDVNO=''' + edtDevice.Text + ''' or(T1.sMC='''+edtDevice.Text+'''))';
    end;

    Str := Str + args;

    FCarryOutSQL(CDSDBA,Str,True,False);
    PSetGroupCount(dxDBGrid1);PSetGroupCount(dxDBGrid1);
end;

procedure TFrm08FuncHistory.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
   PReadAndSaveFormALL(Self,False);
   Action:=caFree;
end;

procedure TFrm08FuncHistory.SpbtnExportClick(Sender: TObject);
begin
    PExportDxGridToExcel(dxDBGrid1);
end;

procedure TFrm08FuncHistory.dxDBGrid1MouseMove(Sender: TObject;
  Shift: TShiftState; X, Y: Integer);
begin
    PHanHuaDxDBGridGroupPanel(dxDBGrid1);
end;

procedure TFrm08FuncHistory.SpbtnExitClick(Sender: TObject);
begin
    Close
end;

end.
